/**
 * 2018年5月6日下午9:51:52
 */
package com.an.nopro.app.framework.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import com.an.nopro.app.framework.entity.SysUser;
import com.an.nopro.app.framework.respository.SysUserRepository;

/**

 * @目的：用户处理.<br>
 * 
 * @author 86171
 * @date 2018年5月6日下午9:51:52
 * 
 */
@Service
public class CustomerUserService implements UserDetailsService {

	/**
	 * 用户接口
	 */
	@Autowired
	private SysUserRepository sysUserRepository;
	/**
	 * huoqu获取用户对像
	 */
	@Override
	public UserDetails loadUserByUsername(String arg0) throws UsernameNotFoundException {
		System.err.println("用户姓名：" + arg0);
		SysUser user = sysUserRepository.findByUsername(arg0);
		if(null == user) {
			throw new UsernameNotFoundException("用户不存在");
		}
		System.err.println("当前用户：" + user);
		return user;
	}

}
